package cn.java75.sp.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * @author oldliu
 * @since 1.0
 */
// s_student表对应
@ApiModel(value = "学生对象", description = "在school中保存学生信息")
public class Student implements Serializable {

    private long stuno;
    private long gradeid;
    @NotBlank(message = "姓名不能为空")
    @Size(min = 2,max = 10,message = "姓名长度必须在2-10之间")
    private String sname;

    @Pattern(regexp = "(男|女|妖)")
    private String sex;
    @Pattern(regexp = "\\d+",message = "QQ号必须是数字")
    private String qq;
    private String wechat;
    @Pattern(regexp = "1\\d{10}",message = "手机必须是1开始的11位数字")
    private String telephone;
    private String address;
    private String fromcity;
    private String email;
    private String pass;
    private String idcardpic;

    //String ->Date
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
    @Past
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date enterdate;

    //
    private String gname;//年级名称

    //
    public Student() {
    }

    public Student(long stuno, long gradeid, String sname, String sex, String qq, String wechat, String telephone, String address, String fromcity, String email, String pass, String idcardpic, Date birthday, Date enterdate) {
        this.stuno = stuno;
        this.gradeid = gradeid;
        this.sname = sname;
        this.sex = sex;
        this.qq = qq;
        this.wechat = wechat;
        this.telephone = telephone;
        this.address = address;
        this.fromcity = fromcity;
        this.email = email;
        this.pass = pass;
        this.idcardpic = idcardpic;
        this.birthday = birthday;
        this.enterdate = enterdate;
    }

    @ApiModelProperty("学号，自动增长，增加的时候无须提供")
    public long getStuno() {
        return stuno;
    }

    public void setStuno(long stuno) {
        this.stuno = stuno;
    }

    @ApiModelProperty("学生所属年级编号")
    public long getGradeid() {
        return gradeid;
    }

    public void setGradeid(long gradeid) {
        this.gradeid = gradeid;
    }

    @ApiModelProperty("学生姓名")
    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    @ApiModelProperty("学生性别，必须是 男  女  妖")
    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @ApiModelProperty("学生QQ号")
    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    @ApiModelProperty("学生微信号")
    public String getWechat() {
        return wechat;
    }

    public void setWechat(String wechat) {
        this.wechat = wechat;
    }

    @ApiModelProperty("学生手机号")
    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @ApiModelProperty("学生地址")
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @ApiModelProperty("学生所属城市")
    public String getFromcity() {
        return fromcity;
    }

    public void setFromcity(String fromcity) {
        this.fromcity = fromcity;
    }

    @ApiModelProperty("学生所属年级名称，查询专用")
    public String getGname() {
        return gname;
    }

    public void setGname(String gname) {
        this.gname = gname;
    }

    @ApiModelProperty("学生电子邮件")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @ApiModelProperty("学生密码")
    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    @ApiModelProperty("学生身份证号图片地址，上传的时候无序指定，自动生成")
    public String getIdcardpic() {
        return idcardpic;
    }

    public void setIdcardpic(String idcardpic) {
        this.idcardpic = idcardpic;
    }

    @ApiModelProperty("学生生日")
    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @ApiModelProperty("学生入学时间")
    public Date getEnterdate() {
        return enterdate;
    }

    public void setEnterdate(Date enterdate) {
        this.enterdate = enterdate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return stuno == student.stuno;
    }

    @Override
    public int hashCode() {
        return Objects.hash(stuno);
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuno=" + stuno +
                ", gradeid=" + gradeid +
                ", sname='" + sname + '\'' +
                ", sex='" + sex + '\'' +
                ", qq='" + qq + '\'' +
                ", wechat='" + wechat + '\'' +
                ", telephone='" + telephone + '\'' +
                ", address='" + address + '\'' +
                ", fromcity='" + fromcity + '\'' +
                ", email='" + email + '\'' +
                ", pass='" + pass + '\'' +
                ", idcardpic='" + idcardpic + '\'' +
                ", birthday=" + birthday +
                ", enterdate=" + enterdate +
                '}';
    }
}
